export const mapInit = function(fn) {
 
		let bool = false
		 
			// android平台
			if (uni.getSystemInfoSync().platform == 'android') {
				var context = plus.android.importClass("android.content.Context");
				var locationManager = plus.android.importClass("android.location.LocationManager");
				var main = plus.android.runtimeMainActivity();
				var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
				bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)
			}
			if (bool === false) {
				uni.showModal({
					title: '提示',
					content: '请打开定位服务',
					success: ({
						confirm,
						cancel
					}) => {
		 
						if (confirm) {
							// android平台
							if (uni.getSystemInfoSync().platform == 'android') {
								var Intent = plus.android.importClass('android.content.Intent');
								var Settings = plus.android.importClass('android.provider.Settings');
								var intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
								var main = plus.android.runtimeMainActivity();
								main.startActivity(intent); // 打开系统设置GPS服务页面
							}
		 
							// ios平台
							if (uni.getSystemInfoSync().platform == 'ios') {
								var UIApplication = plus.ios.import("UIApplication");
								var application2 = UIApplication.sharedApplication();
								var NSURL2 = plus.ios.import("NSURL");
								var setting2 = NSURL2.URLWithString("App-Prefs:root=Privacy&path=LOCATION");
								application2.openURL(setting2);
								plus.ios.deleteObject(setting2);
								plus.ios.deleteObject(NSURL2);
								plus.ios.deleteObject(application2);
							}
						} 
		 
						// 用户取消前往开启定位服务
						if (cancel) {
							console.log('gps检测失败')
							uni.$u.toast('检出到定位服务开启失败')
							// do sth...
						}
					}
				});
			}else{
				console.log('gps检测已开启')
				typeof fn == 'function' && fn({success:bool});
			}
 
}